package com.zengjianjun.es.demo.highlevelclient.example.builder;

import com.zengjianjun.es.demo.highlevelclient.options.TimeOption;
import com.zengjianjun.es.demo.highlevelclient.param.EsQueryParam;
import com.zengjianjun.es.demo.highlevelclient.param.FieldValue;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zengjianjun
 */
@Getter
public class EsActiveQuery extends EsQueryParam {

    public static EsActiveQueryBuilder builder() {
        return new EsActiveQueryBuilder();
    }

    public EsActiveQuery(Map<String, FieldValue<?>> map, TimeOption timeOption) {
        super.putAll(map);
        super.timeOption(timeOption);
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class EsActiveQueryBuilder {

        private final Map<String, FieldValue<?>> map = new HashMap<>();

        private TimeOption timeOption;

        public EsActiveQueryBuilder clickId(FieldValue<String> fieldValue) {
            map.put("clickId", fieldValue);
            return this;
        }

        public EsActiveQueryBuilder offerId(FieldValue<Integer> fieldValue) {
            map.put("offerId", fieldValue);
            return this;
        }

        public EsActiveQueryBuilder publisherId(FieldValue<Integer> fieldValue) {
            map.put("publisherId", fieldValue);
            return this;
        }

        public EsActiveQueryBuilder subAffId(FieldValue<String> fieldValue) {
            map.put("subAffId", fieldValue);
            return this;
        }

        public EsActiveQueryBuilder timeOption(TimeOption timeOption) {
            this.timeOption = timeOption;
            return this;
        }

        public EsActiveQuery build() {
            return new EsActiveQuery(map, timeOption);
        }
    }
}
